package leetcode.editor.cn;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

//Java：独一无二的出现次数
public class UniqueNumberOfOccurrences {
    public static void main(String[] args) {
        Solution solution = new UniqueNumberOfOccurrences().new Solution();
        // TO TEST
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public boolean uniqueOccurrences(int[] arr) {
            Map<Integer, Integer> occur = new HashMap<Integer, Integer>();
            for (int x : arr) {
                occur.put(x, occur.getOrDefault(x, 0) + 1);
            }
            Set<Integer> times = new HashSet<Integer>();
            for (Map.Entry<Integer, Integer> x : occur.entrySet()) {
                times.add(x.getValue());
            }
            return times.size() == occur.size();
        }
    }

//leetcode submit region end(Prohibit modification and deletion)

}